home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / RCNTFILE.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  3KB  |  100 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1995, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.8  $
  6. //
  7. // Definition of TRecentFiles class
  8. //----------------------------------------------------------------------------
  9. #if !defined(OWL_RECENTFILE_H)
  10. #define OWL_RECENTFILE_H
  11.  
  12. #if !defined(OWL_EVENTHAN_H)
  13. # include <owl/eventhan.h>
  14. #endif
  15.  
  16. #if !defined(WINSYS_PROFILE_H)
  17. # include <winsys/profile.h>
  18. #endif
  19.  
  20. #if defined(BI_NAMESPACE)
  21. namespace OWL {
  22. #endif
  23.  
  24. //
  25. // Derived classes should catch the following registered message to know
  26. // when an item in the recent list has been selected.
  27. //
  28. #define MruFileMessage "MRUFILEMESSAGE"
  29.  
  30. // Generic definitions/compiler options (eg. alignment) preceeding the
  31. // definition of classes
  32. #include <services/preclass.h>
  33.  
  34. //
  35. // class TRecentFiles
  36. // ~~~~~ ~~~~~~~~~~~~
  37. // This class implements a most-recent files list, designed to be mixed-in with
  38. // TApplication.
  39. // The list is appended to the menu with CM_EXIT options.
  40. //
  41. class _OWLCLASS TRecentFiles : virtual public TEventHandler
  42. #if defined (BI_NO_RTTI)
  43.   , virtual public TStreamableBase
  44. #endif
  45. {
  46.   public:
  47.     enum { MaxMenuItems = 10 };
  48.  
  49.     TRecentFiles(const char far* iniName, int numSavedFiles = MaxMenuItems);
  50.    ~TRecentFiles();
  51.  
  52.     void          SaveMenuChoice(const char far* text);
  53.     bool          GetMenuText(int id, char far* text, int maxTextLen);
  54.     void          SetMaxMruItems(int max);
  55.  
  56.   protected:
  57.     void          CeExit(TCommandEnabler& ce);
  58.     void          CmFile(uint id);
  59.  
  60.     // Do the MRU items already exists in the menu?
  61.     //
  62.     bool          MruItemsInsertedIntoMenu(HMENU hMenu);
  63.     void          RemoveMruItemsFromMenu(HMENU hMenu);
  64.     void          InsertMruItemsToMenu(HMENU hMenu);
  65.     int           GetMenuPos(HMENU hMenu, uint id);
  66.     int           GetExitMenuPos(HMENU hMenu);
  67.  
  68.     // Profile methods
  69.     //
  70.     int           GetMruCount();
  71.     void          RemoveMruIndex(int index);
  72.     void          AddMruItem(const char far* text);
  73.     bool          ExistMruItem(const char far* text);
  74.     int           GetMruItemIndex(const char far* text);
  75.  
  76.   private:
  77.     // Read information from the .INI file
  78.     //
  79.     void          Read();
  80.  
  81.     static uint   MruMessage;
  82.     int           MaxFilesToSave;
  83.     TProfile*     Profile;
  84.     bool          AddedSeparator;
  85.     HMENU         LastHMenu;
  86.  
  87.   DECLARE_RESPONSE_TABLE(TRecentFiles);
  88.   DECLARE_CASTABLE;
  89. };
  90.  
  91. // Generic definitions/compiler options (eg. alignment) following the
  92. // definition of classes
  93. #include <services/posclass.h>
  94.  
  95. #if defined(BI_NAMESPACE)
  96. } // namespace OWL
  97. #endif
  98.  
  99. #endif  // OWL_RECENTFILE_H
  100.